(deftemplate intrebare (slot stringIntrebare)(slot raspuns))
(assert (intrebare (stringIntrebare nil)(raspuns nil)))

(defrule q1
(intrebare (stringIntrebare nil)(raspuns nil))
=>
(printout t "Este pornit calculatorul? (DA/NU)" crlf)
(bind ?r (read))
(assert (intrebare (stringIntrebare "Este pornit calculatorul?")(raspuns ?r)))
)
(defrule power
(intrebare (stringIntrebare "Este pornit calculatorul?")(raspuns NU))
=>
(printout t "Power on" crlf)
)

(defrule q2
(intrebare (stringIntrebare "Este pornit calculatorul?")(raspuns DA))
=>
(printout t "Are sunet? (DA/NU)" crlf)
(bind ?r (read))
(assert (intrebare (stringIntrebare "Are sunet?")(raspuns ?r)))
)
(defrule sunet
(intrebare (stringIntrebare "Are sunet?")(raspuns NU))
=>
(printout t "Aprinde boxele" crlf)
)

(defrule q3
(intrebare (stringIntrebare "Are sunet?")(raspuns DA))
=>
(printout t "Does computer seek? (DA/NU)" crlf)
(bind ?r (read))
(assert (intrebare (stringIntrebare "Does computer seek?")(raspuns ?r)))
)

(defrule q4
(intrebare (stringIntrebare "Does computer seek?")(raspuns DA))
=>
(printout t "Does booting begin? (DA/NU)" crlf)
(bind ?r (read))
(assert (intrebare (stringIntrebare "Does booting begin?")(raspuns ?r)))
)
(defrule cons
(intrebare (stringIntrebare "Does computer seek?")(raspuns NU))
=>
(printout t "Does computer beep? (DA/NU)" crlf)
(bind ?r (read))
(assert (intrebare (stringIntrebare "Does computer beep?")(raspuns ?r)))
)
(defrule da
(intrebare (stringIntrebare "Does booting begin?")(raspuns DA))
=>
(printout t "Puteti folosi calculatorul." crlf)
)
(defrule nu
(intrebare (stringIntrebare "Does booting begin?")(raspuns NU))
=>
(printout t "Consulta keyboard, RAM, motherboard, power supply" crlf)
)
(defrule er
(intrebare (stringIntrebare "Does computer beep?")(raspuns NU))
=>
(printout t "Error" crlf)
)
(defrule q5
(intrebare (stringIntrebare "Does computer beep?")(raspuns DA))
=>
(printout t "How many beeps? (DA/NU)" crlf)
(bind ?r (read))
(assert (intrebare (stringIntrebare "How many beeps?")(raspuns ?r)))
)
(defrule cons2
(intrebare (stringIntrebare "How many beeps?")(raspuns ?x & : (> ?x 3)))
=>
(printout t "Consulta keyboard, motherboard." crlf)
)
(defrule q6
(intrebare (stringIntrebare "How many beeps?")(raspuns ?x & : (<= ?x 3)))
=>
(printout t "Is RAM loose? (DA/NU)" crlf)
(bind ?r (read))
(assert (intrebare (stringIntrebare "Is RAM loose?")(raspuns ?r)))
)
(defrule cons3
(intrebare (stringIntrebare "Is RAM loose?")(raspuns DA))
=>
(printout t "Remove and reset memory modules." crlf)
)
(defrule cons4
(intrebare (stringIntrebare "Is RAM loose?")(raspuns NU))
=>
(printout t "Replace modules one by one" crlf)
)

(facts)
(agenda)
(run)